import {lazy,Suspense} from 'react';
import { Navigate } from 'react-router-dom';
// 引入加载组件
import Loading from '@/components/Loading'
let Index = lazy(()=>import('@/views/Index'));
let Home = lazy(()=>import('@/views/Home'));
let Cart = lazy(()=>import('@/views/Cart'));
let Mine = lazy(()=>import('@/views/Mine'));
let Info = lazy(()=>import('@/views/Info'));
let Login = lazy(()=>import('@/views/Login'));
let NotFound = lazy(()=>import('@/views/NotFound/404'));
let Address  = lazy(()=>import("@/views/addRess"))
let Add = lazy(()=>import('@/views/Add'))
let ConfrimOrder= lazy(()=>import("@/views/confirmOrder"))
let routes = [
    {
        path:"/index",
        element:<Suspense fallback={<Loading/>}><Index/></Suspense>,
        author:false,
        children:[
            {
                path:"",
                element:<Navigate to='home'></Navigate>,
                author:false,
            },
            {
                path:"home",
                element:<Suspense fallback={<Loading/>}><Home/></Suspense>,
                author:false,
            }, {
                path:"cart",
                element:<Suspense fallback={<Loading/>}><Cart/></Suspense>,
                author:true,
            }, {
                path:"mine",
                element:<Suspense fallback={<Loading/>}><Mine/></Suspense>,
                author:true,
            }
        ]
    },{
        path:"/login",
        element:<Suspense fallback={<Loading/>}><Login/></Suspense>,
        author:false
    },{
        // 动态路由
        path:"/info/:id",
        element:<Suspense fallback={<Loading/>}><Info/></Suspense>,
        author:false,
    },{
        path:"/",
        element:<Navigate to={'/index/home'}></Navigate>,
        author:false
    },{
        path:"*",
        element:<Suspense fallback={<Loading/>}><NotFound/></Suspense>,
        author:false
    },{
        path:"/address",
        element:<Suspense fallback={<Loading></Loading>}><Address/></Suspense>,
        author:true
    },{
        path:"/add/address",
        element:<Suspense fallback={<Loading></Loading>}><Add/></Suspense>,
        author:true
    },{
        path:"/confrimorder",
        element:<Suspense fallback={<Loading></Loading>}><ConfrimOrder/></Suspense>,
        author:true
    }
]


export default routes;